﻿namespace MEF_Test.Bricks.Subtitles
{
    using System.Collections.Generic;
    using System.ComponentModel;

    using MEF_Test.Contracts;

    public class SubtitlesProviderResults : INotifyPropertyChanged
    {     
        #region Constants and Fields

        /// <summary>
        /// The name of the <see cref="IsBusy"/> property.
        /// </summary>
        private readonly string _isBusyPropertyName = PropertyHelper.MemberName<SubtitlesProviderResults>(results => results.IsBusy);

        /// <summary>
        /// The name for the <see cref="IsSuccessful"/> property.
        /// </summary>
        private readonly string _isSuccessfulPropertyName = PropertyHelper.MemberName<SubtitlesProviderResults>(results => results.IsSuccessful);

        /// <summary>
        /// The name of the <see cref="Subtitles"/> property.
        /// </summary>
        private readonly string _subtitlesPropertyName = PropertyHelper.MemberName<SubtitlesProviderResults>(results => results.Subtitles);

        /// <summary>
        /// The backing field for the <see cref="IsBusy"/> property.
        /// </summary>
        private bool _isBusy;

        /// <summary>
        /// The backing field for the <see cref="IsSuccessful"/> property.
        /// </summary>
        private bool _isSuccessful;

        /// <summary>
        /// The backing field for the <see cref="Subtitles"/> property.
        /// </summary>
        private IEnumerable<ISubtitleViewModel> _subtitles;


        #endregion

        #region Events

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets a value indicating whether this instance is busy.
        /// </summary>
        /// <value><c>true</c> if this instance is busy; otherwise, <c>false</c>.</value>
        public bool IsBusy
        {
            get
            {
                return _isBusy;
            }

            set
            {
                if (value != _isBusy)
                {
                    _isBusy = value;
                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs(_isBusyPropertyName));
                    }
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is successful.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is successful; otherwise, <c>false</c>.
        /// </value>
        public bool IsSuccessful
        {
            get
            {
                return _isSuccessful;
            }

            set
            {
                if (value != this._isSuccessful)
                {
                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs(_isSuccessfulPropertyName));
                    }

                    this._isSuccessful = value;
                }
            }
        }

        /// <summary>
        /// Gets or sets the name of the provider.
        /// </summary>
        /// <value>The name of the provider.</value>
        public string ProviderName { get; set; }

        /// <summary>
        /// Gets or sets the subtitles.
        /// </summary>
        /// <value>The subtitles.</value>
        public IEnumerable<ISubtitleViewModel> Subtitles
        {
            get
            {
                return this._subtitles;
            }

            set
            {
                if (value != this._subtitles)
                {
                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs(_subtitlesPropertyName));
                    }

                    this._subtitles = value;                    
                }
            }
        }

        #endregion
    }
}